package ds.factcom.domain.client;

import java.util.List;

import ds.factcom.domain.Domain;
import ds.factcom.domain.invoice.Invoice;
import ds.factcom.domain.payment.Payment;

/**
 * Cliente abstracto que posee el comportamiento de saber cual su propia forma de operar con las facturas.
 * Como tambien si un cliente vip o no.
 * @author Javier De Luca, Maximiliano Herrera, Matias Samblancat
 */
public class Client extends Domain{

	/**
	 * 
	 */
	private static final long serialVersionUID = 4369849444368988212L;
	
	private static Integer idLast = 0;
	private String name;	
	private String address;
	private Document document;

	
	//############ esto es para la bidireccionalidad ####################
	private List<Invoice> invoices;
	private List<Payment> payments;

	
	public Client(String name, String documentType, String documentNumber, String address, List<Invoice> invoices, List<Payment> payments) {
		idLast = this.generateId();
		this.setId(idLast);
		this.address = address;
		this.document = new Document(documentType, documentNumber);
		this.invoices = invoices;
		this.payments = payments;
		this.name=name;
	}

	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public Document getDocument() {
		return document;
	}
	public void setDocument(Document document) {
		this.document = document;
	}
	
	@Override
	protected Integer getLastId() {
		return idLast;
	}

	@Override
	public boolean equals(Object obj) {
		Client client = (Client)obj;
		return this.document.equals(client.getDocument());
	}

	//############ esto es para la bidireccionalidad ####################
	public void setInvoices(List<Invoice> invoices) {
		this.invoices = invoices;
	}

	public List<Invoice> getInvoices() {
		return invoices;
	}

	public List<Payment> getPayments() {
		return payments;
	}

	public void setPayments(List<Payment> payments) {
		this.payments = payments;
	}

}
